#pragma once

#include <arpa/inet.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <string>

class Inet
{
    void ConvertToHost(const sockaddr_in &addr)
    {
        _ip = inet_ntoa(addr.sin_addr);
        _port = ntohs(addr.sin_port);
    }

public:
    Inet(sockaddr_in addr)
        : _addr(addr)
    {
        ConvertToHost(_addr);
    }
    std::string IP()
    {
        return _ip;
    }
    uint16_t PORT()
    {
        return _port;
    }
    ~Inet()
    {
    }
private:
    std::string _ip;
    uint16_t _port;
    sockaddr_in _addr;
};
